package top.tenebrous.yzl.im.enums;

import lombok.Getter;

import java.util.Objects;

@Getter
public enum ChatType {

    PUBLIC_CHAT_TYPE("1","PUBLIC_CHAT_TYPE"),
    PRIVATE_CHAT_TYPE("2","PRIVATE_CHAT_TYPE");

    private final String code;
    private final String value;

    private ChatType(String code, String value) {
        this.code = code;
        this.value = value;
    }

    public static ChatType getMessageType(String code) {
        for (ChatType chatType : values()) {
            if (Objects.equals(chatType.code, code)) {
                return chatType;
            }
        }
        throw new IllegalArgumentException("unknown data type code");
    }
}
